#ifndef __IMAGE_IDENTIFY_H__
#define __IMAGE_IDENTIFY_H__

#include <stdio.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <pthread.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

//#include "opencv.hpp"
#include "visionLanding.hpp"
//#include "mycalib3d.hpp"

#include "thread_common_op.h"
#include "../wireless_debug/wireless_debug.h"
#include <semaphore.h>
#include "../pilot/autopilot_interface.h"
#include "../HealthManage/HealthManage.h"

//#include "route.h"


#define OFFSET_GET_ID_A	0x02
#define OFFSET_GET_ID_B	0x04
/* #define OFFSET_GET_ID_*	0x** */

//x:right, y:forward
#define INSTALLATION_OFFSET_X 0.0
#define INSTALLATION_OFFSET_Y 25.0


typedef struct
{
	float x;
	float y;
	float z;
}ref_position_vision_t;

typedef struct
{
	ref_position_vision_t 	position;
	int 					gotten;
}vision_data_t;

class xy_vision_c
{

public:

	bool is_on;
	ref_position_vision_t position;
	int get_id;
	uint8_t cap_unopen_flag;
	vision_data_t vision_data;
	int itgr_count;
	float vision_height;
	//int used_target_point_cout;
	//int get_target_point_cout;
	xy_vision_c();
	~xy_vision_c();
	
	int get_data(ref_position_vision_t *_data, int _get_id, float height);
	int start_capture(void);
	int stop_capture(void);
	int setup_capture(void);
	void clear_sample_states(void);
	int close_capture(void);
	int ctreate_capture_and_identify_thread(void);
	int check_offset_data_if_available(int _get_id);
	void set_offset_data(Point3f _point);
	ref_position_vision_t get_vision_data(int _get_id);
	//void point2loc(const float& u, const float& v, const float& Z, const string& camconf, float& X, float& Y);
};

int mk_image_store_dir(void);
void set_vision_height(float height);
int use_gps_height_filter_offset(Point3f* dist, Point3f src, float height);
int get_current_cnt_in_profile(void);




#endif
